package xyz.robinbingo.effectivejava.chapter04.item17;

import java.math.BigInteger;

/**
 * @author Robin
 * @date 2019/03/28 16:41
 **/
public class A extends BigInteger {


    /**
     * Translates the decimal String representation of a BigInteger into a
     * BigInteger.  The String representation consists of an optional minus
     * sign followed by a sequence of one or more decimal digits.  The
     * character-to-digit mapping is provided by {@code Character.digit}.
     * The String may not contain any extraneous characters (whitespace, for
     * example).
     *
     * @param val decimal String representation of BigInteger.
     * @throws NumberFormatException {@code val} is not a valid representation
     *                               of a BigInteger.
     * @see Character#digit
     */
    public A(String val) {
        super(val);
    }

    public static BigInteger safeInstance(BigInteger val) {
        return val.getClass() == BigInteger.class ? val : new BigInteger(val.toByteArray());
    }

}
